/*
 * Copyright (c) 2007 Compl Yue Still, All Rights Reserved.
 */

package oex.tasks;

import hbi.domain.Gateway;
import hbi.task.TaskAgent;
import hbi.task.TaskScript;

import java.util.Date;

import oex.ObjectExplorer;
import oex.ObjectWorld;

public class Greeting implements TaskAgent<ObjectWorld, ObjectExplorer>
{

    public void arrived(
        Gateway<? extends ObjectWorld, ? extends ObjectExplorer> gateway)
    {
        System.err.println("Greeting arrived!");
    }

    public void sayHello(String from)
    {
        System.err.println("Hello from " + from + " !");
    }

    public void greetPeople(String... names)
    {
        for (String name : names)
            System.err.println("Hey " + name + ", wasup!");
    }

    public void displayNumbers(double[] numbers)
    {
        System.err.println("There are " + numbers.length + " numbers:");
        for (double n : numbers)
            System.err.println("  " + n);
    }

    public void finishTask(
        Gateway<? extends ObjectWorld, ? extends ObjectExplorer> gateway)
    {
        System.err.println("Greeting finished!");

        gateway.sendTaskAgent(Feedback.class, new TaskScript<Feedback>()
        {
            public void run(Feedback agent)
            {
                agent.showFeedback("This is feedback from Java world!", 1, 5.5,
                    "haha", System.currentTimeMillis(), new Date());
            }
        });
    }

}
